package DataLayer;
/**
 * @author: Lam Thanh Trung 1101706
 * @purpose: Lop dung de ket noi vao csdl
 * @Date: 18/9/2013
 */
import java.sql.DriverManager;
import java.sql.Connection;
import javax.swing.JOptionPane;

public class ChatConnection {
    
    public static Connection getConnetion(){
        Connection con=null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            String conStr = "jdbc:mysql://localhost/ChatApplication?useUnicode=true&characterEncoding=UTF-8";//chuoi ket noi csdl
            con = DriverManager.getConnection(conStr, "root", "root");//khai bao tk - mk cua csdl
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null,"loi ket noi");
        }
        return con;
    }
    
    public static void closeConnetion(Connection con){
        try{
            if(con != null){
                con.close();
            }
        }
        catch(Exception e){
        }
    }
}
